<?php
// 应用公共文件

use think\facade\Db;
use think\facade\Request;

function returnJson($code = 0, $msg = 'Succ', $data = '', $count = '', $data0 = '')
{
    header('Content-Type:application/json; charset=utf-8');
    $result = [
        'code' => $code,
        'msg' => $msg,
        'data' => $data,
    ];
    if ($count != '') {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
            'count' => $count
        ];
    }
    if ($data0 != '') {
        $result = [
            'code' => $code,
            'msg' => $msg,
            'data' => $data,
            'data0' => $data0
        ];
    }
    return json($result);
}

function log_other($log='未输入文本'){
    Db::table('log_other')->insert(['log'=>$log]);
    return True;
}
function log_action($method='空方法',$state='空结果',$ip='0.0.0.0',$qq='000'){
    $data = [
        'method'=>$method,
        'state'=>$state,
        'ip'=>$ip,
        'qq'=>$qq,
    ];
    Db::table('log_action')->insert($data);
    return True;
}

